package com.nulldev.util.concurrency.threadIt.v4.utils.impls;

import java.util.List;
import java.util.concurrent.TimeUnit;

import com.nulldev.util.JVM.JVM;
import com.nulldev.util.concurrency.threadIt.v4.emapi.ExecutorManager;
import com.nulldev.util.concurrency.threadIt.v4.emapi.uft.Executable;
import com.nulldev.util.io.FastIO.FastIO;

public class TaskTraceTest {

	public static void main(String[] args) {
		final Executable<Object> test = ExecutorManager.globalAsyncSubmit(() -> {
			((Object) null).hashCode();
			return false;

//			final long start = System.currentTimeMillis();
//			while (true) {
//				try {
//					Thread.sleep(1000L);
//				} catch (InterruptedException e) {
//				}
//
//				if ((System.currentTimeMillis() - start) >= 10_000_000)
//					break;
//			}
//			return true;
		});

		final List<Executable<?>> list = ExecutorManager.get().awaitFor(1, TimeUnit.SECONDS, test);
		if (!list.isEmpty()) {
			TaskUtils.printWithTrace(list);
		} else {
			JVM.println("awaitFor completed successfully.");
		}

		FastIO.get().flush();
		JVM.exit();
	}

}
